package com.gscitysfy.cus.drain.task;

import com.gscitysfy.cus.drain.modules.inspection.service.IDrainInspectionMnJobService;
import com.gscitysfy.cus.drain.modules.inspection.service.IDrainInspectionMnPlanService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.Date;

/**
 * @author Administrator
 * @date: 2022/7/26 10:51
 * @Description: 定时任务类
 */
@Component
@EnableScheduling
@EnableAsync
@Slf4j
public class TimerTask {
    @Autowired
    IDrainInspectionMnJobService drainInspectionMnJobService;

    @Resource
    private IDrainInspectionMnPlanService planService;
    /**
     * @auther: wuxinxin
     * @date: 2022/7/26 10:55
     * @Description: 定时生成巡检任务
     * @return void
     */
    @Async
    @Scheduled(cron = "*/30 * * * * ?")
    public void updateEquipInfoCodeStatus() {
        planService.createJob();
        log.info("巡检任务生成日期：{}", new Date());

        planService.createOrder();
        log.info("维护任务生成日期：{}", new Date());
    }


    @Scheduled(cron = "0 */10 * * * ?")
    public void scheduleTask() {
        drainInspectionMnJobService.getStutas();
    }


}
